package reaction.europarl.queries;

import java.util.Comparator;

public class QueryELComparator implements Comparator<QueryEL> {
	
		@Override
	    public int compare(QueryEL q1, QueryEL q2) {
			
			final int BEFORE = -1;
		    final int EQUAL = 0;
		    final int AFTER = 1;
		    int value = 0;
		    
		    String[] query1_parts = q1.query_id.split("-");
		    String[] query2_parts = q2.query_id.split("-");
		    
		    Integer qid1 = new Integer(Integer.parseInt(query1_parts[query1_parts.length-1]));
			Integer qid2 = new Integer(Integer.parseInt(query2_parts[query1_parts.length-1]));

		    if (qid1 == qid2 ) value = EQUAL;
		    if (qid1 > qid2) value = AFTER;
		    if (qid1 < qid2) value= BEFORE;
		    
		    return value;
	    }
}